package com.nega.commons.enums;

import java.io.Serializable;

public enum MessageCode implements Serializable {

    SUCCESS("操作成功", "0000"),

    FAILURE("操作失败", "0001"),

    EXIST("数据已存在", "0002"),

    UNEXIST("数据不存在", "0003"),

    ILLEGAL_ARGUMENT("参数不合法", "0004"),

    UNALLOWED("操作不允许", "0005"),

    SYS_ERROR("系统出错", "0006");

    private String desc;

    private String code;

    private MessageCode(String desc, String code) {
        this.desc = desc;
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 获取 code
     * @return code
     */
    public String getCode() {
        return code;
    }

    public static MessageCode find(String code) {
        for (MessageCode messageCode : values()) {
            if (messageCode.getCode().equals(code)) {
                return messageCode;
            }
        }
        return null;
    }
}